<!DOCTYPE html>
<html lang="en">
<head>
    <title>销售管理层-陪同拜访</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="Cache-Control" content="no-store, must-revalidate">
    <meta http-equiv="expires" content="Wed, 26 Feb 1997 08:21:57 GMT">
    <meta http-equiv="expires" content="-1">
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"
          name="viewport">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <style>
        [v-cloak] {
            display: none;
        }

        * {
            -webkit-box-sizing: border-box;
            -moz-box-sizing: border-box;
            box-sizing: border-box;
        }

        body {
            margin: 1px;
        }

        table {
            border-spacing: 0;
            border-collapse: collapse;
            display: table;
        }

        table.text-center, table.text-center td, table.text-center th {
            text-align: center;
            font-size: x-small;
        }

        .table-bordered > thead > tr > th, .table-bordered > tbody > tr > th, .table-bordered > tfoot > tr > th, .table-bordered > thead > tr > td, .table-bordered > tbody > tr > td, .table-bordered > tfoot > tr > td {
            border: 1px solid #cbcbcd;
        }

        .table th {
            background: yellow;
        }

        table td {
            padding-top: 5px;
            padding-bottom: 5px;
            padding-left: 2px;
            padding-right: 2px;
            position: relative;
        }

        .table-bordered {
            border: 1px solid #cbcbcd;
        }

        .table {
            width: 100%;
            max-width: 100%;
            margin-bottom: 20px;
        }

        .hidden {
            display: none;
        }

        .tryStyle {
            width: 30px;
            height: 16px;
            font-size: 10px;
            right: 0;
            position: absolute;
            border-radius: 5px;
            margin-top: 2px;
            background: red;
            color: #fff;
            margin-right: 5px;
            transform: scale(0.7);
        }
    </style>
</head>
<body>
<section class="content" id="app">
    <div class="row">
        <table style="max-width: 600px" class="table table-bordered text-center" id="myTable">
            <thead>
            <tr>
                <th style="width: 60px;text-align: center">大区<br/>经理</th>
                <th style="width: 60px;text-align: center">陪跑</br>区域经理</th>
                <th style="width: 50px;text-align: center">
                    在职<br>状态
                </th>
                <th style="width: 50px;text-align: center">
                    入职<br>天数
                </th>
                <th style="width: 60px;text-align: center">客户电话</th>
                <th style="width: 60px;text-align: center">客户<br/>姓名</th>
                <th style="width: 40px;text-align: center">客户<br>微信号</th>
                <th style="width: 50px;text-align: center">拜访<br/>时长</th>
            </tr>
            </thead>
            <tbody v-cloak>
            <tr v-for="(item, i) in sendData">
                <td :rowspan="item.managerNamespan" :class="{hidden: item.managerNamedis}">
                    {{item.managerName}}
                </td>
                <td :rowspan="item.entourageNamespan" :class="{hidden: item.entourageNamedis}"
                    style="text-align: center">{{item.entourageName}}
                </td>
                <td :rowspan="item.jobStatespan" :class="{hidden: item.jobStatedis}">
                    {{Flage2Name(item.jobState)}}
                </td>
                <td style="text-align: center" :rowspan="item.dayNumberspan"
                    :class="{hidden: item.dayNumberdis}">{{item.dayNumber}}
                </td>
                <td style="text-align: center">{{item.customerTel}}</td>
                <td style="color:#169BD5;cursor: pointer;text-align: center"
                    @click="lookRegionList(item)">{{item.customerName}}
                </td>
                <td style="text-align: center">{{item.customerWechat}}</td>
                <td style="text-align: center" v-if="item.time=='0'">{{item.time}}分</td>
                <td style="text-align: center" v-else>{{item.time}}</td>
            </tr>
            </tbody>
        </table>
    </div>
    <!-- /.box-body -->
</section>
<!--oa自定义  JS-->
<script src="https://file.ggxqce.com/web/jquery-2.2.3.min.js"></script>
<script src="https://file.ggxqce.com/web/vue.min.js"></script>
<script src="/dist/js/oaApp.js"></script>
<script type="text/javascript">
    $(function () {
        $("body").on("click", ".reginTd", function (e) {
            var text = $(this).text();
            if (text != "") {
                text = "<i></i>" + text;
                $(".div-td-content-more").html(text).css({
                    "width": $(this).outerWidth() + "px",
                    "left": $(this).offset().left,
                    "top": ($(this).offset().top + $(this).outerHeight()) + "px"
                }).show();
                e.stopPropagation();
            }
        });
        $("body").on("click", ".div-td-content-more", function (e) {
            e.stopPropagation();
        });
        $("body").on("click", function () {
            $(".div-td-content-more").hide();
        });
    });

</script>
<script type="text/javascript">
    function getUrlParam(name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
        var r = window.location.search.substr(1).match(reg);  //匹配目标参数
        if (r != null) return unescape(r[2]);
        return null; //返回参数值
    }
    function getUrlParamObj() {
        var args = new Object();
        var query = location.href;
        var pairs = query.split("&"); //www.cxybl.com break at ampersand
        for (var i = 0; i < pairs.length; i++) {
            var pos = pairs[i].indexOf('='); // look for "name=value"
            if (pos == -1) continue; // if not found, skip
            var argname = pairs[i].substring(0, pos); // extract the name
            var pos1 = argname.indexOf('?');
            if (pos1 > -1) {
                argname = argname.substring(pos1 + 1);
            }
            var value = pairs[i].substring(pos + 1); // extract the value
            value = decodeURIComponent(value); // decode it, if needed
            args[argname] = value; // store as a property
        }
        var ss = args.valueOf(0);
        obj = args;
        return args;
    }

    function isDay(time) {
        //2018-01-01
        if (time.length > 8) {
            return true
        } else {
            return false
        }
    }


    var app = new Vue({
        el: '#app',
        data: {
            userId: getUrlParamObj().userId,
            entourageName: getUrlParamObj().entourageName,
            dateTime: getUrlParam('dateTime'),
            isDay: isDay(getUrlParam('dateTime')),
            hour: new Date().getHours(),
            sendData: [],
        },
        methods: {
            //  查看下属
            lookRegionList: function (item) {
                //url = "/reportForm/signIn/departList.html?flag=1&companyId=" + item.companyId + "&companyName=" + item.companyName + "&time=" + that.time + "&isToday=" + that.isToday;
                prompt(JSON.stringify(item))
            },
            Flage2Name: function (flage) {
                if (flage == "-2") return "试岗";
                if (flage == "-1") return "试用期";
                if (flage == "0") return "在职";
                if (flage == "1") return "离职";
                if (flage == "2") return "档案不全";
            },
            tablesMergeCell: function (list) {
                for (field in list[0]) {
                    var k = 0;
                    while (k < list.length) {
                        list[k][field + 'span'] = 1;
                        list[k][field + 'dis'] = false;
                        for (var i = k + 1; i <= list.length - 1; i++) {
                            if (list[k][field] == list[i][field] && list[k][field] != '' || list[k][field] == 0 && list[i][field] == 0) {
                                list[k][field + 'span']++;
                                list[k][field + 'dis'] = false;
                                list[i][field + 'span'] = 1;
                                list[i][field + 'dis'] = true;
                            } else {
                                break;
                            }
                        }
                        k = i;
                    }
                }
                return list;
            },
            getList: function () {
                var that = this;
                var data = {
                    userId: that.userId,
                    isDay: that.isDay,
                    dateTime: that.dateTime,
                    entourage: that.entourageName,
                }
                console.log(JSON.stringify(data))
                $.ajax({
                    url: server.ip + urlConfig.crm.customer.getCustomerByManage,
                    contentType: 'application/json;charset=utf-8',
                    type: "POST",
                    data: JSON.stringify(data),
                    success: function (r) {
                        var res = JSON.parse(r)
                        that.sendData = that.tablesMergeCell(res.data.sendData);
                    },
                    error: function (e) {
                        alert(e.responseText)
                    }
                });
            }
        },
        mounted: function () {
            this.getList();
        }

    });
</script>

</body>
</html>